<!--# layout("/common/layout.html",{"jsBase":"/js/customer/customerInfo/"}){ -->

<form class="layui-form layui-form-pane" id="addForm" enctype="multipart/form-data"  lay-filter="editform">
    <input type="hidden" name="customerId" id="customerId">
    <input type="hidden" name="scoreId" id="scoreId">
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">省份</label>
                <div class="layui-input-inline">
                    <layui:simpleDataSelect name="provinceId" id="provinceId" value="${has(customerInfo)?customerInfo.provinceId:''}" data="${provinceList}"
                                            attrId="provId" attrName="provName" laySearch="true"  layFilter="colFilter"/>
                </div>
            </div>
        </div>
    </div>

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">年份</label>
                <div class="layui-input-inline">
                    <input type="text" name="choiceYear"  id="choiceYear" autocomplete="off" class="layui-input input-time">
                </div>
            </div>


        </div>
    </div>

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">高考分数</label>
                <div class="layui-input-inline">
                    <input type="text" name="score" id="score" autocomplete="off" class="layui-input" readonly>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">高考排名</label>
                <div class="layui-input-inline" >
                    <input type="text" name="rank" id="rank" autocomplete="off" class="layui-input" readonly>
                </div>
            </div>

        </div>
    </div>
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">已经锁分</label>
                <div class="layui-input-inline" >
                                    <span style="line-height:38px;margin-left:8px">
                                        ${customerInfo.isConfirmed==1?"已锁分":"未锁分"}
                                    </span>
                </div>
                <label class="layui-form-label">解锁次数</label>
                <div class="layui-input-inline" >
                                    <span style="line-height:38px;margin-left:8px">
                                        ${customerInfo.unlockCount}
                                    </span>
                </div>
            </div>

        </div>
    </div>
    <div class="layui-row">
        <div class="layui-form-item">
            <button class="layui-btn layui-btn-danger" type="button" id="scoreButton">分数解锁</button>
            <button class="layui-btn layui-btn-danger" type="button" id="addButton" lay-submit lay-filter="form">保存</button>
            <button class="layui-btn layui-btn-primary" style="display:none" type="button" id="addButton-loading" >保存中...</button>
            <button class="layui-btn" type="button" id="addButton-cancel">取消</button>
        </div>
    </div>

</form>
<table id="customerLogTable" lay-filter="customerLogTable"></table>
<!--#} -->
<script>
    layui.define([ 'form', 'laydate', 'table','customerInfoApi'], function(exports) {
        var form = layui.form;
        var table = layui.table;
        var laydate = layui.laydate;
        var customerInfoApi = layui.customerInfoApi;
        laydate.render({
            elem: '#choiceYear'
            ,type: 'year'
        });
        var view = {
            init:function(){
                Lib.initGenrealForm($("#addForm"),form);
                this.initSubmit();
            },
            initSubmit:function(){
                $("#scoreButton").click(function(){
                    Common.post("/customer/customerInfo/unlockScore.json", {"scoreId": '${customerInfo.scoreId}',"customerId":'${customerInfo.customerId}'}, function () {
                        Common.info("解锁成功");
                        Lib.closeFrame();
                    })
                });
                $("#addButton").click(function(){
                    form.on('submit(form)', function(){
                        customerInfoApi.saveExam($('#addForm'),function(){
                            parent.window.dataReload();
                            Common.info("保存成功");
                            Lib.closeFrame();
                        });
                    });
                });
                $("#addButton-cancel").click(function(){
                    Lib.closeFrame();
                });
            }

        }
        view.init();
        <!--# if(!(isEmpty(customerInfoJson))){  -->
        var formJson = ${customerInfoJson};
        form.val("editform",formJson);
        $(".image-preview").each(function() {
            $(this).attr("src",formJson[$(this).attr("id")]);
        });
        customerLogTable = table.render({
            elem: '#customerLogTable',
            height: Lib.getTableHeight(0),
            cellMinWidth: 100,
            method: 'post',
            url: Common.ctxPath + '/customer/customerInfo/log.json?customerId=${customerInfo.customerId}' // 数据接口
            , page: false
            ,cols: [[ // 表头
                {
                    field: 'operationRemark',
                    title: '操作说明',
                },
                {
                    field: 'createdName',
                    title: '操作人',
                },
                {
                    field: 'createdTime',
                    title: '操作时间',
                }

            ]]

        });
        <!--# } -->
    });
</script>
